home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-02 | 4.6 KB | 123 lines | [TEXT/MPS ] |
- {
- segment loader:
- public interface definition
- by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
- Copyright 1987 - 1991 Apple Computer, Inc. All rights reserved.
- }
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := 0}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT LoaderRoutines;
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED UsingLoaderRoutines}
- {$SETC UsingLoaderRoutines := 1}
-
-
- {$I+}
- {$SETC LoaderRoutinesIncludes := UsingIncludes}
- {$SETC UsingIncludes := 1}
- {$IFC UNDEFINED UsingMemoryTypes}
- {$I $$Shell(PInterfaces)MemoryTypes.p}
- {$ENDC}
- {$SETC UsingIncludes := LoaderRoutinesIncludes}
-
- CONST
- returnSegmentSize = 1;
- returnSegmentData = 2;
- returnSegmentCount = 3;
- returnTaskReturnStack = 4;
-
-
- TYPE
- SegmentSpoolType = LongInt;
- SegmentSpoolTypePointer = ^SegmentSpoolType;
- SegmentSpoolTypeArray = ARRAY [0..0] OF SegmentSpoolType;
-
-
- SegmentSpoolFunction = ProcPtr;
- SegmentSpoolFunctionPointer = ^SegmentSpoolFunction;
- SegmentSpoolFunctionArray = ARRAY [0..0] OF SegmentSpoolFunction;
-
-
-
- {$IFC UNDEFINED VoidDefined}
- {$SETC VoidDefined := 1}
- VOID = RECORD END;
- {$ENDC}
-
- LoaderClient = ^Void;
- LoaderClientPointer = ^LoaderClient;
- LoaderClientArray = ARRAY [0..0] OF LoaderClient;
-
- PROCEDURE InitializeLoader; C;
-
- { these routines allocate and dispose of loader clients }
- FUNCTION NewLoaderClient(memoryStart: Ptr; memoryLength: LongInt; spoolFunc: SegmentSpoolFunction; userReference: LongInt): LoaderClient; C;
- PROCEDURE DisposeLoaderClient(client: LoaderClient); C;
-
- { these routines return the non-modifiable fields of a loaderClient }
- FUNCTION GetLoaderClientGlobals(client: LoaderClient): Ptr; C;
- FUNCTION GetLoaderClientGlobalsStart(client: LoaderClient): Ptr; C;
- FUNCTION GetLoaderClientHeap(client: LoaderClient): GxHeapPointer; C;
-
- { these routines get and set the modifiable fields of a loaderClient }
- FUNCTION GetLoaderClientUserReference(client: LoaderClient): LongInt; C;
- PROCEDURE SetLoaderClientUserReference(client: LoaderClient; newRef: LongInt); C;
- FUNCTION GetLoaderClientSpoolFunction(client: LoaderClient): SegmentSpoolFunction; C;
- PROCEDURE SetLoaderClientSpoolFunction(client: LoaderClient; newFunc: SegmentSpoolFunction); C;
-
- { these must be switched at process switch time if several processes are using the loaderClient }
- FUNCTION GetLoaderClientReturnStack(client: LoaderClient): Ptr; C;
- PROCEDURE SetLoaderClientReturnStack(client: LoaderClient; newStack: Ptr); C;
- FUNCTION GetLoaderClientLastBlock(client: LoaderClient): Ptr; C;
- PROCEDURE SetLoaderClientLastBlock(client: LoaderClient; lastBlock: Ptr); C;
-
- { this routine disposes of all the unlocked segments in the loaderClient’s code gxHeap }
- PROCEDURE FlushLoaderSegments(client: LoaderClient); C;
-
- {
- this routine loads the segment that contains the function pointed to by address, locks this segment down and makes
- it permanent by patching the jump table to jump straight into it. this segment can never be moved or disposed of after
- this, since the segment loader no longer has any way of knowing whether some process is currenly executing in it or
- not
- }
-
- PROCEDURE LoadPermanentSegment(address: Ptr); C;
-
- {
- this routine aborts all the functions entered in the return stack from its current position back to the passed saveStack
- value. the lockCounts for all these functions will be updated properly and the returnStack and lastBlock will be restored
- }
-
- PROCEDURE CleanupLoaderReturnStack(client: LoaderClient; savedStack: Ptr); C;
-
- { these routines lock and unlock access to the loader client’s code gxHeap. the first one also sets the busy counts for code blocks correctly }
- PROCEDURE LockLoaderClientMemory(client: LoaderClient); C;
- PROCEDURE UnlockLoaderClientMemory(client: LoaderClient); C;
-
- { this routine validates the passed loaderClient to ensure that it is a loaderClient and it hasn’t been damaged }
- PROCEDURE ValidateLoaderClient(client: LoaderClient); C;
-
- { this returns the size of the patchRecord that Patch and Unpatch LoaderClientFunction use }
- FUNCTION GetLoaderClientPatchSize: LongInt; C;
-
- { you must call these routines to create and destroy patch records for jump table entries }
- FUNCTION PatchLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer; patchAddress: Ptr): Ptr; C;
- PROCEDURE UnpatchLoaderClientFunction(client: LoaderClient; patchAddress: Ptr); C;
-
- { once the patch record has been created, these functions allow jump table entries to be redirected }
- FUNCTION GetLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer): Ptr; C;
- PROCEDURE SetLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer; newAddress: Ptr); C;
-
-
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-